package Practice;

import java.util.Arrays;
import java.util.Scanner;

public class Climber {
    static class Point {
        int x, y, z;

        public Point(int x, int y, int z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }
    }

    public static double distance(Point a, Point b) {
        return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2) + Math.pow(a.z - b.z, 2));
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Point[] points = new Point[N];
        for (int i = 0; i < N; i++) {
            points[i] = new Point(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
        }
        scanner.close();

        Arrays.sort(points, (a, b) -> Integer.compare(a.z, b.z));

        double totalDistance = 0;
        for (int i = 1; i < N; i++) {
            totalDistance += distance(points[i - 1], points[i]);
        }
        System.out.printf("%.3f", totalDistance);
    }
}

